package com.dmap.admin.controller.background;

import com.dmap.admin.service.backgroundv1.UserPermissionManageService;
import com.dmap.admin.vo.UserPermissionVo;
import com.dmap.base.constants.Constant;
import com.dmap.base.vo.BaseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * \* User: silent
 * \* Date: 08/12/17 Time: 11:28
 * \* Description:
 * \
 */
@Api(value = "用户权限管理", description = "background/用户权限管理")
@Controller
@RequestMapping(value = "/background/pmpd-admin-server/v1/UserPermissionManage")
public class UserPermissionManageController {

    @Resource
    private UserPermissionManageService userPermissionManageService;

    @ResponseBody
    @ApiOperation(value = "根据用户ID查询权限列表", notes = "require userId")
    @RequestMapping(value = "select/selectUserPermissionByUserId", method = RequestMethod.GET)
    public BaseVo selectUserPermissionByUserId(@RequestParam(name = "userId") String userId) {
        BaseVo baseVo = new BaseVo();
        if (StringUtils.isEmpty(userId)) {
            baseVo.setCode(Constant.RESPONSE_PARAM_ERROR_CODE);
            baseVo.setMsg(Constant.RESPONSE_PARAM_ERROR_MSG);
            return baseVo;
        }
        UserPermissionVo userPermissionVo = userPermissionManageService.selectUserPermissionsByUserId(Long.valueOf(userId));
        baseVo.setData(userPermissionVo);
        return baseVo;
    }

}